﻿using System.Collections.Generic;
using Domep.Server.BusinessObjects;
using System.Data.Entity;

namespace Domep.Server.Services.Kernel.DBCommunication
{
    public abstract class Retriever
    {
        protected ServerContext db;
        protected Retriever()
        {
            db = new ServerContext();
        }
    }

    public class ApplianceRetriever : Retriever
    {
        public ApplianceRetriever() : base() { }
        public List<Appliance> GetAppliances()
        {
            #region bouchon obsolète
            //TODO Implémenter ici le vrai protocol

            //List<Appliance> appliances = new List<Appliance>();

            //List<Functionality> functionalities = new List<Functionality>();
            //Functionality f1 = new Functionality("Allumer", "Allumer l'appareil", "Signature1");
            //Functionality f2 = new Functionality("Eteindre", "Eteins l'appareil", "Signature2");
            //Functionality f3 = new Functionality("Fourer", "Foure", "Signature3");
            //Functionality f4 = new Functionality("MicroOnder", "Microonde", "Signature4");

            //functionalities.Add(f1);
            //functionalities.Add(f2);
            //functionalities.Add(f3);

            //appliances.Add(new Appliance(new System.Net.IPAddress(0X2414188f),"00-11-22-33-44-55","Four",new ApplianceModel("Four","MarqueDuFour",ApplianceType.Oven,functionalities),"ReferenceDuFour","SerialNumberDuFour",1,1));

            //functionalities = new List<Functionality>();
            //functionalities.Add(f1);
            //functionalities.Add(f2);
            //functionalities.Add(f4);
            //appliances.Add(new Appliance(new System.Net.IPAddress(0X2414188f), "11-22-33-44-55-66", "Micro-Ondes", new ApplianceModel("Micro-Ondes", "MarqueDuMicroOndes", ApplianceType.MicrowaveOven, functionalities), "ReferenceDuMicroOndes", "SerialNumberDuMicroOndes", 2, 2));

            //return appliances;
            #endregion
            return new List<Appliance>(db.Appliances);
        }
    }

    public class FunctionalityRetriever : Retriever
    {
        public FunctionalityRetriever() : base() { }
        public List<Functionality> GetFunctionalities()
        {
            return new List<Functionality>(db.Functionalities);
        }
    }

    public class ApplianceModelRetriever : Retriever
    {
        public ApplianceModelRetriever() : base() { }
        public List<ApplianceModel> GetApplianceModels()
        {
            return new List<ApplianceModel>(db.ApplianceModels);
        }
    }
}
